package heima3_2.cn.osc.presenter;

import java.util.List;

import heima3_2.cn.osc.model.bean.GeneralNewsBean;
import heima3_2.cn.osc.ui.main_fragment.SyntheFragment;
import retrofit2.Call;
import retrofit2.Response;

/**
 * Created by Administrator on 2017/1/14 0014.
 */

public class SynthePresenter extends BasePresenter<GeneralNewsBean> {
    private  SyntheFragment syntherMainFragment;

    public SynthePresenter(SyntheFragment syntherMainFragment){
        this.syntherMainFragment=syntherMainFragment;
    }

    @Override
    protected void getFailureData(Throwable t) {
        t.printStackTrace();
    }

    @Override
    protected void getSuccessData(Response<GeneralNewsBean> response) {
        GeneralNewsBean body = response.body();
        List<GeneralNewsBean.NewsBean> newslist = body.getNewslist();

        syntherMainFragment.mAdapter.setDatas(newslist);
    }

    @Override
    public void getData(int pager) {
        Call<GeneralNewsBean> info = mRetrofitInterface.getInfo(0, 1, 20);
        info.enqueue(mCallback);
    }
}
